using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using THSLib;using THSERP.BaseProvider;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;

namespace THSERP.Modules.Report
{
    public partial class ARRP004InvoiceItemsGridControl : THSGridControl
    {
        protected override void AddColumnsToGridView(string strTableName, DevExpress.XtraGrid.Views.Grid.GridView gridView)
        {
            base.AddColumnsToGridView(strTableName, gridView);

            DevExpress.XtraGrid.Columns.GridColumn col = new DevExpress.XtraGrid.Columns.GridColumn();
            col.FieldName = "ARInvoiceItemSupplierName";
            col.Caption = "Supplier";
            col.OptionsColumn.AllowEdit = false;
            gridView.Columns.Add(col);
        }

        protected override void GridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            base.GridView_FocusedRowChanged(sender, e);
            DevExpress.XtraGrid.Views.Grid.GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)sender;
            if (gridView != null)
            {
                object objValue = gridView.GetRowCellValue(e.FocusedRowHandle, "FK_ICProductID");
                if (objValue != null)
                {
                    ((RP004)Screen).GetInvoiceItemBranchByAttribute(Convert.ToInt32(objValue.ToString()));
                }
            }
        }
        protected override void OnClick(EventArgs ev)
        {
            DevExpress.XtraGrid.Views.Grid.GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)this.Views[0];
            if (gridView != null)
            {
                int iRowHandle = gridView.FocusedRowHandle;
                if (iRowHandle >= 0)
                {
                    object objValue = gridView.GetRowCellValue(iRowHandle, "FK_ICProductID");
                    if (objValue != null)
                    {
                        ((RP004)Screen).GetInvoiceItemBranchByAttribute(Convert.ToInt32(objValue.ToString()));
                    }
                }
            }
        }
    }
}
